Python Data Science Cookbook by 2015
Author: 2015 , Date: September 6, 2017
, Views: 238
This is the function to find the closest prototype vector for a given vector:def find_closest(in_vector,proto_vectors): closest = None closest_distance = 99999 for p_v in proto_vectors: distance = euclidean_distances(in_vector,p_v.p_vector) if distance < closest_distance: closest_distance = distance closest = p_v return closest
A convenient function to find the class ID of the closest prototype vector is as follows:def find_class_id(test_vector,p_vectors): return find_closest(test_vector,p_vectors).class_id
Copyright Disclaimer:
This site does not store any files on its server. We only index and link
to content provided by other sites. Please contact the content providers
to delete copyright contents if any and email us, we'll remove relevant
links or contents immediately.